import time
from pathlib import Path

import execjs

with open(Path(__file__).parent / "pdd_util.js", "r", encoding="utf-8") as f:
    ANTI_CONTENT_CTX = execjs.compile(f.read())


def gen_anti_content(config_dict=None, cookie=None, data=None):
    if not config_dict:
        config_dict = {
            "serverTime": int(time.time() * 1000),
        }
    return ANTI_CONTENT_CTX.call("gen_anti_content", config_dict, cookie, data)
